24 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
25 #define For(i, a, b) for (int i=(a); i<(b); ++i)
26 #define D(x) cout << #x " is " << x << endl
30 int myFloor(int n
, int k
) {
34 int myCeil(int n
, int k
) {
35 return (n
+ k
- 1) / k
;
43 if (memo
[n
][s
] != -1) return memo
[n
][s
];
45 int best
= 1 + max( f(myFloor(n
-1, 2), s
-1), f(myCeil(n
-1, 2), s
) );
47 return memo
[n
][s
] = best
;
53 memset(memo
, -1, sizeof memo
);
57 assert(s
> 0 and n
> 0);
59 printf("%d %d = %d\n", n
, s
, ans
);